const GET_STORIES = 'GET_STORIES'
const GET_THEME_CATEGORY = 'GET_THEME_CATEGORY'
const CHANGE_SCROLL = 'CHANGE_SCROLL'
const GET_CATE_STORIES = 'GET_CATE_STORIES'
const GET_NEWS_DETAIL = 'GET_NEWS_DETAIL'
const GET_NEWS_EXTRA = 'GET_NEWS_EXTRA'
const GET_LONG_COMMENTS = 'GET_LONG_COMMENTS'
const GET_SHORT_COMMENTS = 'GET_SHORT_COMMENTS'
const GET_RECOMMENDERS = 'GET_RECOMMENDERS'
const CHANGE_TRANSITION = 'CHANGE_TRANSITION'


export default {
  [GET_STORIES](state, payload) {
      state.stories = payload.response.data.stories
      state.top_stories = payload.response.data.top_stories
  },

  [GET_THEME_CATEGORY](state, payload) {
    state.themeCategories = payload.response.data.others
  },

  [CHANGE_SCROLL](state) {
    state.stopScroll = !state.stopScroll
  },
  [CHANGE_TRANSITION](state) {
    state.transitionName = 'slide-left'
    setTimeout(()=>{
      state.transitionName = 'slide-right'
    },2000)
  },

  [GET_CATE_STORIES](state, payload) {
    state.cateStories.background = payload.response.data.background
    state.cateStories.stories = payload.response.data.stories
    state.cateStories.editors = payload.response.data.editors
    state.cateStories.name = payload.response.data.name
    state.cateStories.description = payload.response.data.description
  },

  [GET_NEWS_DETAIL](state, payload) {
    state.newsDetail.body = payload.response.data.body
    state.newsDetail.title = payload.response.data.title
    state.newsDetail.image = payload.response.data.image
    state.newsDetail.imageSource = payload.response.data.image_source
    state.newsDetail.css = payload.response.data.css
    state.newsDetail.recommenders = payload.response.data.recommenders
  },

  [GET_NEWS_EXTRA](state, payload) {
    state.newsExtra.comments = payload.response.data.comments
    state.newsExtra.longComments = payload.response.data.long_comments
    state.newsExtra.shortComments = payload.response.data.short_comments
    state.newsExtra.popularity = payload.response.data.popularity
  },

  [GET_LONG_COMMENTS](state,payload) {
    state.longComments = payload.response.data.comments
  },

  [GET_SHORT_COMMENTS](state,payload) {
    state.shortComments = payload.response.data.comments
  },

  [GET_RECOMMENDERS](state,payload) {
    state.recommenders = payload.response.data.editors
  }


}
